#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;

void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = n;
    for(int i = 1; i < s.size(); i++) {
        if(s[i] != s[0]) {
            ans += n - i;
            break;
        }
    }
    if(ans == n) ans--;
    cout << ans << endl;
}

signed main() {
    int t = 1;
    cin >> t;
    while(t--) solve();
    return 0;
}